package cn.bugstack.mybatis.type;

import java.lang.reflect.Type;
import java.sql.Types;
import java.util.HashMap;
import java.util.Map;

/**
 * @author wcc
 * @description Jdbc类型枚举
 * @create
 */

public enum JdbcType {
    INTEGER(Types.INTEGER),

    VARCHAR(Types.VARCHAR),
    BIGINT(Types.BIGINT),
    CHAR(Types.CHAR),

    TIMESTAMP(Types.TIMESTAMP),

    DECIMAL(Types.DECIMAL),

    DOUBLE(Types.DOUBLE),

    FLOAT(Types.FLOAT);
    private final int TYPE_CODE;
    private static Map<Integer, JdbcType> codeLookup = new HashMap<>();
    static {
        for (JdbcType type : JdbcType.values()){
            codeLookup.put(type.TYPE_CODE, type);
        }
    }

    JdbcType(int code) {
        this.TYPE_CODE = code;
    }

    public static JdbcType forCode(int code){
        return codeLookup.get(code);
    }
}
